package com.woniuxy.movice.service.imp;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.woniuxy.movice.dto.AllComment;
import com.woniuxy.movice.entity.Cinema;
import com.woniuxy.movice.mapper.CinemaMapper;
import com.woniuxy.movice.service.CinemaService;

import lombok.Data;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.woniuxy.movice.entity.Cinema;
import com.woniuxy.movice.mapper.CinemaMapper;
import com.woniuxy.movice.service.CinemaService;

import lombok.Data;

@Data
@Service
public class CinemaServiceImp implements CinemaService{

	@Resource
	private CinemaMapper cinemaMapper;
	
	@Override
	public List<Cinema> showAllCinema() {
		return cinemaMapper.showAllCinema();
	}
	
	@Override
	public Cinema showCinemaById(int yid) {
		// TODO Auto-generated method stub
		return cinemaMapper.showCinemaById(yid);
	}

	@Override
	public List<AllComment> showAllComment() {
		return cinemaMapper.showComment();
	}

	@Override
	public String addComment(float agrade, String acomment,int uid) {
		String result="评论失败";
		Date date=new Date();
		SimpleDateFormat df=new SimpleDateFormat("yyyy-MM-dd");
		String adate=df.format(date);
		int re=cinemaMapper.addCommentInf(agrade,acomment,uid,adate);
		if(re>0) {
			result="评论成功";
		}
		return result;
	}
}
